<!--
 * @Author: 关棺 3156298705@qq.com
 * @Date: 2024-12-17 16:22:55
 * @LastEditors: 关棺 3156298705@qq.com
 * @LastEditTime: 2024-12-17 16:46:15
 * @FilePath: \supervision-ui\src\views\file\fileVersion\components\leaveMessage.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <el-dialog title="文件留言列表" :visible.sync="dialogVisible" width="500px">
    <el-table v-loading="loading" :data="commentList">
      <el-table-column label="留言内容" align="center" prop="commentContent" />
      <el-table-column
        label="留言时间"
        align="center"
        prop="commentTime"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.commentTime, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">取 消</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { listComment } from "@/api/file/comment";
export default {
  data() {
    return {
      dialogVisible: false, // 控制弹出框显示/隐藏
      messageForm: {
        content: "", // 留言内容
        commentTime: "",
      },
      id: "",
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        fileId: null,
        total: 0,
      },
      // 遮罩层
      loading: true,
      // 文件留言表格数据
      commentList: [],
      total: 0,
    };
  },
  methods: {
    // 显示留言弹出框
    showLeaveMessageDialog(id) {
      // console.log(id);
      this.id = id;
      this.messageForm.content = "";
      this.messageForm.commentTime = "";
      this.dialogVisible = true;
      this.queryParams.fileId = id;
      this.getList();
    },
    getList() {
      this.loading = true;
      listComment(this.queryParams).then((response) => {
        this.commentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
  },
};
</script>

<style scoped>
/* 自定义样式 */
</style>
